#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	cin>>t;
	while(t--){
		int n,m,l,v;
		int ans=0;
		cin>>n>>m>>l>>v;
		int s=0;
		double d[100005],cv[100005],a[100005],p[100005];
		for(int i=1;i<=n;i++){
			cin>>d[i]>>cv[i]>>a[i];
			if(a[i]>0){
				s=1;
			}
			else if(a[i]<0){
				s=-1;
			}
			if(cv[i]>v){
				ans++;
			}	
		}

		for(int i=1;i<=m;i++){
			cin>>p[i];
		}
		if(s==0){
			cout<<ans<<" "<<m-1<<endl;
		}

		if(s==1){
			for(int i=1;i<=n;i++){
				if(d[i]<p[m]){
					if(p[m]-d[i]>(cv[i]-v)/2*a[i]*(cv[i]+v))ans++;
				}
			}
			cout<<ans<<" "<<m-1<<endl;
		}
	}
	return 0;
}
